Data writing method and storage device

ABSTRACT

This application provides a data writing method and a storage device. The method is applied to a solid-state storage device SSD, and the method includes: receiving a write command, where the write command carries a type of to-be-written data; determining, based on the type of to-be-written data, a type of storage area that is in an SSD and into which the to-be-written data is written, where the SSD includes a plurality of types of storage areas; determining, based on the type of storage area, a target storage area into which the to-be-written data is written; and writing the to-be-written data into the target storage area. In embodiments of this application, data processing efficiency can be improved.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No. PCT/CN2018/107798, filed on Sep. 27, 2018, which claims priority to Chinese Patent Application No. 201711007552.5, filed on Oct. 25, 2017. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

This application relates to the computer field, and more specifically, to a data writing method and a storage device.

BACKGROUND

With continuous development of storage technologies, a solid state drive (SSD) that uses a NAND flash as a storage medium gradually becomes a mainstream storage form. The NAND flash is a non-volatile random access storage medium, and a feature of the storage medium is that data is not lost after power-off.

Currently, the NAND flash stores data in a plurality of blocks based on a receiving sequence, to improve concurrency. The data is randomly stored in each page in the blocks. However, different pages have different data storage performance. For example, pages may be classified into three types: a least significant bit LSB page, a central significant bit CSB page, a most significant bit MSB page. In addition, performance of the LSB page, the CSB page, and the MSB page sequentially decreases.

Therefore, in a current storage method, a storage device is less efficient at storing data of applications with different processing requirements.

SUMMARY

This application provides a data writing method and a storage device, to improve data processing efficiency.

According to a first aspect, a data writing method is provided. The method includes: receiving a write command, where the write command carries a type of to-be-written data; determining, based on the type of to-be-written data, a type of storage area that is in an SSD and into which the to-be-written data is written, where the SSD includes a plurality of types of storage areas; determining, based on the type of storage area, a target storage area into which the to-be-written data is written; and writing the to-be-written data into the target storage area.

A storage device receives the write command that carries the type of to-be-written data, determines, based on the type of to-be-written data, the type of storage area into which the to-be-written data is written, and then determines, based on the type of storage area, the target storage area into which the to-be-written data is written. In this way, the storage device can store the data in a proper storage area. In other words, the storage device can meet different requirements of applications. Therefore, data processing efficiency and system performance are improved.

In some possible implementations, the SSD stores a correspondence between a data type and a storage area type, and the determining, based on the type of to-be-written data, a type of storage area that is in an SSD and into which the to-be-written data is written includes: determining, based on the type of to-be-written data and the correspondence, a type of target storage area into which the to-be-written data is written.

The storage device can determine, based on the correspondence between the data type and the storage area type and the type of to-be-written data, the type of target storage area into which the to-be-written data is written. In this way, efficiency of writing data into the storage device is further improved.

In some possible implementations, the SSD includes a plurality of storage blocks, the SSD is divided into different types of storage areas based on types of the storage blocks, and the correspondence is a correspondence between the data type and a storage block type.

The storage device can determine, based on the correspondence between the data type and the storage block type and the type of to-be-written data, a type of target storage block into which the to-be-written data is written. In this way, efficiency of writing data into the storage device and reliability of data writing can be improved.

In some possible implementations, the SSD includes a plurality of storage blocks, each storage block includes at least one type of storage page, the SSD is divided into different types of storage areas based on storage page types, and the correspondence is a correspondence between the data type and the storage page type.

The storage device can determine, based on the correspondence between the data type and the storage page type and the type of to-be-written data, a type of target storage page into which the to-be-written data is written. In this way, at least one of a read latency, a write latency, and read/write reliability can be improved.

In some possible implementations, different types of each storage pages are corresponding to one storage list, and each storage list records one type of storage page; and the determining, based on the type of storage area, a target storage area into which the to-be-written data is written includes: finding, based on a storage page type, an available storage page in a storage list corresponding to the storage page type, and using the available storage page as the target storage area; and if there is an available storage page in the storage list, using the available storage page as the target storage area; or if there is no available storage page in the storage list, obtaining an idle storage block in the SSD, and using a first storage page in the idle storage block as the target storage area.

The storage device may be compatible with a conventional solution in which a writing method of writing data into a block based on a page sequence is used. In this case, reliability of writing data into the storage device is improved while compatibility with the conventional solution is implemented.

In some possible implementations, the SSD includes at least two of an SLC (single level cell) area, an MLC (multi-level cell) area, a TLC (triple level cell) area, and a QLC (quad level cell) area, performance of the SLC area, the MLC area, the TLC area, and the QLC area sequentially decreases, and before the determining, based on the type of storage area, a target storage area into which the to-be-written data is written, the method further includes: if there is no idle storage page in all storage blocks in a storage area corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written, converting a type of at least one block that includes an idle storage page and that is in a storage area having lower performance than the type of storage area that is in the SSD and into which the to-be-written data is written to a type that is the same as a type of storage area of the type of storage area that is in the SSD and into which the to-be-written data is written.

In the storage device, if there is no block that includes an available idle page in the storage area of the type of storage area that is in the SSD and into which the to-be-written data is written, the storage device may convert a block in the MLC area, the TLC area, or the QLC area to a block in the SLC area. To be specific, the storage device may convert a block in a storage area having low performance to a block in a storage area having higher performance. In this way, a waste of an idle resource in the storage area with a high-performance priority is avoided, and resource utilization of the storage device is improved.

In some possible implementations, the storage block includes at least two of an LSB page, a CSB page, and the MSB page, performance of the LSB page, the CSB page, and the MSB page sequentially decreases, and the determining, based on the type of storage area, a target storage area into which the to-be-written data is written includes: if a storage area of the type of storage area that is in the SSD and into which the to-be-written data is written is the MSB page or the CSB page, and there is no available storage page in the storage area of the type of storage area that is in the SSD and into which the to-be-written data is written, determining, as the target storage area, at least one available storage page having higher performance than the type of storage area that is in the SSD and into which the to-be-written data is written.

When there is no available idle page in pages corresponding to a page type having low performance, the storage device may determine an available idle page having higher performance as the target storage area. In this way, a waste of an idle resource in the available page having higher performance is avoided, and resource utilization of the storage device is improved.

According to a second aspect, a storage device is provided. The storage device includes a module configured to perform the method in the first aspect or any possible implementation of the first aspect.

According to a third aspect, a storage device is provided. The storage device includes a processor, a memory, and a communications interface. The processor is connected to the memory and the communications interface. The memory is configured to store an instruction, the processor is configured to execute the instruction, and the communications interface is configured to communicate with another network element under control of the processor. When the processor executes the instruction stored in the memory, the processor performs the method in the first aspect or any possible implementation of the first aspect.

According to a fourth aspect, a computer storage medium is provided. The computer storage medium stores program code, and the program code is used to indicate an instruction used to perform the method in the first aspect or any possible implementation of the first aspect.

According to a fifth aspect, a system chip is provided. The system chip includes an input/output interface, at least one processor, at least one memory, and a bus. The at least one memory is configured to store an instruction, and the at least one processor is configured to invoke the instruction in the at least one memory to perform an operation in the method in the foregoing aspects.

Based on the foregoing solution, the storage device receives the write command that carries the type of to-be-written data, determines, based on the type of to-be-written data, the type of storage area into which the to-be-written data is written, and then determines, based on the type of storage area, the target storage area into which the to-be-written data is written. In this way, the storage device can store the data in a proper storage area. In other words, the storage device can meet different requirements of applications. Therefore, data processing efficiency and system performance are improved.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic structural diagram of a floating gate transistor;

FIG. 2 is a schematic structural diagram of a LUN (logical unit number);

FIG. 3 is a schematic diagram of characteristics of different storage cells in a NAND flash;

FIG. 4 is a schematic diagram of level distribution of different storage cells in a block;

FIG. 5 is a schematic diagram of a sharing relationship between pages in a block;

FIG. 6 is a schematic diagram of data storage of a current NAND flash;

FIG. 7 is a schematic flowchart of a data writing method according to an embodiment of this application;

FIG. 8 shows a table of a mapping relationship between values of bits and latencies according to an embodiment of this application;

FIG. 9 is a schematic diagram of data storage according to an embodiment of this application;

FIG. 10 is a schematic diagram of data reading according to another embodiment of this application;

FIG. 11 is a schematic flowchart of a data writing method according to another embodiment of this application;

FIG. 12 is a schematic diagram of a data writing method according to another embodiment of this application;

FIG. 13 is a schematic diagram of a data writing method according to another embodiment of this application;

FIG. 14 is a schematic block diagram of a storage device according to an embodiment of this application; and

FIG. 15 is a schematic structural diagram of a storage device according to an embodiment of this application.

DESCRIPTION OF EMBODIMENTS

The following describes technical solutions of this application with reference to accompanying drawings.

With continuous development of storage technologies, a solid state disk (SSD) that uses a NAND flash as a storage medium gradually becomes a mainstream storage form. The NAND flash is a non-volatile random access storage medium and has features: no data loss after power-off, a large capacity, a fast reading/writing rate, and applicability to massive data storage. Compared with performance of a conventional hard disk drive (HDD) that uses a magnetic medium, there is a qualitative leap in performance of the SSD. Specifically, the SSD can process hundreds of thousands of commands per second.

Currently, a mainstream NAND flash is designed based on a floating gate transistor. A floating gate is configured to hold a charge. In this way, the charge is stored in the floating gate, and the charge can still be kept without a power supply. FIG. 1 is a schematic diagram of a basic structure of a floating gate transistor. As shown in FIG. 1, a NAND flash is designed as a dual-gate transistor, and includes a source, a drain, a gate, a floating gate, a silicon substrate, and an insulation layer. The floating gate is located between the gate and the silicon substrate and is separated from the silicon substrate by the insulation layer. The insulation layer may include oxygen-nitrogen-oxygen or silicon dioxide (SiO2). A charge potential well that stores a charge may be formed in the floating gate transistor. The floating gate records information by holding a charge.

The floating gate transistor may obtain a threshold voltage of the transistor based on whether the floating gate stores a charge or a quantity of stored charges, and indicate data information by using the obtained threshold voltage of the transistor. One floating gate transistor is corresponding to one cell of the NAND flash. A process of writing data into the cell (that is, a programming process) is a process of injecting a charge into the charge potential well. The NAND flash charges the floating gate through F-N tunneling (Fowler Nordheim Tunneling) by using the silicon substrate. However, before programming is performed on the NAND flash, original data needs to be erased. An erasing process is to release a charge in the floating gate through the F-N tunneling.

After the data in the NAND flash is erased, there is no charge in the cell, and a read threshold voltage is a low level. For example, the low level may be represented by data of “1”. After the programming is performed, a charge is injected into the cell, and a read threshold voltage is a high level, and the high level may be represented by data of “0”.

A block is a minimum unit that is in the NAND flash and on which an erasing operation can be performed, and usually includes a plurality of pages. A page is a minimum unit on which a programming operation and a reading operation can be performed, and usually has a size of 4 KB/8 KB/16 KB, or the like. As shown in FIG. 2. A cell is a minimum unit that is in the page and on which an erasing/writing/reading operation can be performed, is corresponding to one floating gate transistor, and can store one or more bits.

Data reading/writing operations of the NAND flash mainly include erasing, programming (or writing), and reading. The programming operation and the reading operation are performed on a per-page basis, and the erasing operation is performed on a per-block basis.

In this embodiment of this application, based on different bit data stored in the cell, storage areas in the NAND Flash may be classified into a single level cell (SLC), a multi-level cell (MLC), a triple level cell (TLC), a quad level cell (QLC), and the like. The storage areas of different structures are different in aspects such as performance and reliability. For example, as shown in FIG. 3, the storage areas of different structures are different in a reading rate, a writing rate, an erasing rate, a quantity of erasing/writing times, a data retention capability, costs, a density, and an operating current.

Specifically, the SLC stores only 1-bit data. In other words, charges of the floating gate are differentiated by using two levels corresponding to 0 and 1, to represent one information bit, as shown in FIG. 4. A quantity of erasing times of the SLC usually is 50 K or 100 K, and the SLC has features such as a long lifetime, high performance, and a high price. The MLC may store 2-bit data, and a data density is relatively large. Four levels corresponding to 00, 01, 10, and 11 in the floating gate may represent two information bits. A quantity of erasing/writing times of the MLC usually is approximately 3 K, and the MLC has features such as a relatively short lifetime, relatively low performance, and a relatively low price. The TLC may store 3-bit data, and a data density is larger. Eight levels corresponding to 000, 001, 010, 011, 100, 101, 110, and 111 in the floating gate may represent three information bits. Erasing/writing can usually be performed on the TLC for hundreds of times. The TLC has features such as a short lifetime, low performance, and a low price. The QLC may store 4-bit data. 16 levels corresponding to 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, and 1111 in the floating gate may represent four information bits. Usually, performance of the QLC is poorer than the performance of the TLC.

In many cases, in a 16 nm MLC, three pages in one block share a set of storage space. As shown in FIG. 5, a page 48, a page 49, and a page 112 share a set of storage space. Further, the pages sharing the set of storage space may be divided into three types. The page 48 is corresponding to a least significant bit LSB page, the page 49 is corresponding to a central significant bit CSB page, and the page 112 is corresponding to a most significant bit MSB page. The LSB page has a read latency of 40 μs and has a strongest data retention capability, the CSB page has a read latency of 70 μs and has a second strongest data retention capability, and the MSB page has a read latency of 112 μs and has a weaker data retention capability.

Currently, the NAND flash stores data in a plurality of blocks based on a receiving sequence, to improve concurrency. As shown in FIG. 6, the NAND flash sequentially stores data based on a sequence of receiving the data. To be specific, the NAND flash sequentially stores data according to a write command (CMD) 1, a CMD 2, and a CMD 3. The data is randomly stored in each page in the blocks. However, because different pages are different in data storage performance, in a current storage method, a storage device is less efficient at storing data of applications with different processing requirements.

FIG. 7 is a schematic flowchart of a data writing method according to an embodiment of this application. The method includes the following steps.

701. A storage device receives a write command sent by an upper-layer application, where the write command carries a type of to-be-written data.

The storage device in this embodiment of this application is an SSD that includes a NAND flash.

The storage device communicates, by using a non-volatile memory control (NVMe) protocol, with a host at which the upper-layer application is located, and a write command defined in the NVMe protocol carries the type of to-be-written data. In this embodiment, the type of to-be-written data is identified by using a write latency requirement of a write request. Specifically, as shown in FIG. 8, a write latency field is defined in the write command in NVMe. In the write latency field, different latency requirements are defined, and the latency requirements of the write command respectively are identified by using 00b, 01b, 10b, and 11b. 00b indicates that the write request does not require a latency (No latency information provided). In other words, an application has no time length requirement for writing the data. 01b indicates that the write request may accept a longer latency (Longer latency acceptable). In other words, the application may accept a longer time length of writing the data. 10b represents a typical latency. In other words, for the application, a required time length of writing the data is a relatively typical time length. 11b represents a smallest possible latency. In other words, the application requires a relatively short time length of writing the data. When delivering the command, the upper-layer application may select one of the latency requirements to represent the type of to-be-written data.

It should be noted that the write command further carries a logical address of the to-be-written data and a length of the to-be-written data.

702. The storage device determines, based on the type of to-be-written data carried in the write command, a type of storage area into which the to-be-written data is written.

In an embodiment, the storage device may determine, based on the type of to-be-written data and a correspondence that is stored in the SSD and that is between the data type and the storage area type, a type of target storage area into which the to-be-written data is written.

Specifically, the storage device may directly determine, based on the type of to-be-written data and the correspondence, the target storage area where the to-be-written data is written, or may indirectly determine the target storage area where the to-be-written data is written.

For example, if there is the type of to-be-written data in a correspondence, a storage area type corresponding to the type of to-be-written data in the correspondence may be determined as the type of target storage area. If there is no type of to-be-written data in a correspondence, a storage area type corresponding to another type similar to the type of to-be-written data may be determined as the type of target storage area.

Optionally, in blocks included in storage areas corresponding to different storage area types, different bits are used to store data.

For example, the storage area may be a single level storage cell SLC area in which 2 bits are used to store data, or may be a multi-level storage cell MLC area in which 4 bits are used to store data, or may be a triple level storage cell TLC area in which 8 bits are used to store data, or may be a quad level storage cell QLC area in which 16 bits are used to store data.

It should be understood that the storage area may be another storage area in which more than 16 bits are used to store data. This is not limited in this application.

In another embodiment, the SSD includes a plurality of storage blocks, the SSD is divided into different types of storage areas based on types of the storage blocks, and the correspondence is a correspondence between the data type and a storage block type.

Specifically, the storage device includes the different types of storage areas, and the different types of storage areas are different in storage performance. In the storage device, a mapping relationship between the type of to-be-written data and a storage block type may be preset. For example, a storage block type corresponding to 00b in the write latency field may be configured as the SLC storage area, a storage block type corresponding to 01b may be configured as the MLC storage area, a storage block type corresponding to 10b may be configured as the TLC storage area, and a storage block type corresponding to 11b may be configured as the QLC storage area. In this way, after receiving the write command, the storage device may determine, based on the type of to-be-written data in the write command, a type of storage block into which the to-be-written data is written.

For example, the SSD may include at least one of the SLC storage area, the MLC storage area, the TLC storage area, and the QLC storage area. All cells included in one block may be of a same type, and blocks of a same type form a type of storage area. For example, a plurality of blocks of an SLC type form an SLC storage area, a plurality of blocks of an MLC type form an MLC storage area, and blocks of a TLC type form a TLC storage area.

As shown in FIG. 9, an application in a host stores to-be-written data in a storage area of an SSD. Storage areas may be divided into four levels of areas: an SLC area, an MLC area, a TLC area, and a QLC area.

It should be noted that performance of the SLC area, the MLC area, the TLC area, and the QLC area can be sorted based on data processing efficiency, reliability, or the like. For example, compared with the other three types of areas, the SLC area has highest data processing efficiency, and performance of the area may be considered to be the highest.

It should be understood that, in the following embodiments, a storage area obtained through division performed on a per-block basis may be referred to as “a block storage area”.

703. Determine, based on the type of storage area, a target storage area into which the to-be-written data is written.

After the type of storage area into which the to-be-written data is written is determined, the to-be-written data may be written into an idle area in the storage area selected from the corresponding type of storage area. For example, at least one idle block in block storage areas of the type of storage area that is in the SSD and into which the to-be-written data is written is used as the target storage area.

Optionally, if there is no idle block in the storage area of the type of storage area that is in the SSD and into which the to-be-written data is written, the storage device may convert a type of block in another type of storage area to a type that is the same as that of a block included in the storage area of the type of the storage area that is in the SSD and into which the to-be-written data is written.

For example, some blocks in the MLC area, the TLC area, or the QLC area may be converted to blocks of an SLC type, to improve storage performance.

Optionally, the storage device may reduce storage volumes of some blocks in the MLC area, the TLC area, or the QLC area, to improve storage performance of the some blocks. For example, the storage device may reduce storage volumes of some blocks in the MLC area, and then convert the some blocks to blocks of the SLC type.

704. The storage device writes the to-be-written data into the target storage area.

Optionally, after determining the target storage area, the storage device may return acknowledgement information to the application. The application may send the to-be-written data to the storage device, and the storage device stores the to-be-written data in the target storage area after receiving the to-be-written data.

Optionally, the storage device may further receive a read command. The read command is used as a request to read data, and the read command carries a type of data that is to be read as required. Further, a scheduling type of data that is to be read as required is determined based on the type of data.

Specifically, the storage device places the read commands in different scheduling queues based on types of data carried in the read commands. The storage device preferably schedules a type of data whose priority level is high, and stores the type of data whose priority level is high in a type of storage area whose priority level is high. In this way, a read response time is shorter, and a requirement of the application is further met.

For example, as shown in FIG. 10, if a read command 8 and a read command 1 carry a type of data whose priority level is high, a read command 2 and a read command 3 carry a type of data whose priority level is medium, and a read command 5 and a read command 0 carry a type of data whose priority level is low, the storage device may preferably schedule the read command 8 and the read command 1, then schedule the read command 2 and the read command 3, and finally schedule the read command 5 and the read command 0.

Therefore, in the data writing method in this embodiment of this application, the storage device receives the write command that carries the type of to-be-written data, determines, based on the type of to-be-written data, the type of storage block into which the to-be-written data is written, and then determines, based on the type of storage block, a target storage block into which the to-be-written data is written. In this way, the storage device can store the data in a proper storage block. In other words, the storage device can meet different requirements of applications. Therefore, data processing efficiency and system performance are improved.

FIG. 11 is a schematic flowchart of a data writing method according to another embodiment of this application.

1101. A storage device receives a write command sent by an upper-layer application, where the write command carries a type of to-be-written data.

It should be understood that implementation of this step may be the same as that of step 701 in the foregoing embodiment. To avoid repetition, details are not described herein again.

1102. The storage device determines, based on the type of to-be-written data carried in the write command, a type of storage area into which the to-be-written data is written.

In an embodiment, the storage device may determine, based on the type of to-be-written data and a correspondence that is stored in the SSD and that is between the data type and the storage area type, a type of target storage area into which the to-be-written data is written.

Optionally, pages in blocks included in storage areas corresponding to different storage area types are different in a read latency, a write latency, and/or read/write reliability.

In another embodiment, the SSD includes different types of storage blocks, such as an SLC storage block, an MLC storage block, and a TLC storage block. Each type of storage block may further include different types of storage pages. For example, the SLC storage block includes at least one of an LSB page, a CSB page, and an MSB page. In this embodiment, the storage area type of storage device is a storage page type.

Specifically, the SSD may include an LSB page, a CSB page, and an MSB page. The LSB Page has lowest storage performance, the CSB page has higher storage performance than the LSB page, and storage performance of the most significant bit MSB page is higher than the storage performance of the CSB page. In the storage device, a mapping relationship between the data type of to-be-written data and a storage page type may be preset. For example, a page type corresponding to 00b and 01b in the write latency field may be configured as the LSB page, a page type corresponding to 10b may be configured as the CSB page, and a page type corresponding to 11b may be configured as the MSB page. In this way, after receiving the write command, the storage device may determine, based on the type of to-be-written data in the write command, a type of page into which the to-be-written data is written. In other words, the storage device can write the to-be-written data into a proper page. Therefore, data storage performance is improved.

Optionally, the page may be the least significant bit LSB page, the central significant bit CSB page, the most significant bit MSB page, or another page.

Specifically, the storage device may divide a storage area into pages with at least two performance levels based on performance and reliability. The least significant bit LSB page has lowest performance, the central significant bit CSB page has higher performance than the LSB page, and performance of the most significant bit MSB page is higher than the performance of the CSB page. In this way, the storage device may select a corresponding page type based on a correspondence between the type of to-be-written data and the page type. Therefore, the storage device can better serve at least two applications having different requirements. In this way, system performance is improved.

For example, as shown in FIG. 9, four storage areas: an SLC area, an MLC area, a TLC area, and a QLC area in a storage area may be replaced with three types of areas: an LSB page, a CSB page, and an MSB page.

It should be understood that each block may include different types of pages.

1103. The storage device determines, based on the type of storage area, the target storage area into which the to-be-written data is written.

After the type of storage area into which the to-be-written data is written is determined, the to-be-written data may be written into an idle area in the storage area selected from the corresponding type of storage area. For example, at least one idle page corresponding to a page type corresponding to the type of the storage area that is in the SSD and into which the to-be-written data is written is used as the target storage area.

Optionally, different types of each storage pages may be corresponding to one storage list, and each storage list records one type of storage page. The storage device may find, based on a storage page type, an idle storage page in a storage list corresponding to the storage page type, and use the idle storage page as the target storage area. If there is an available storage page in the storage list, the storage device may use the available storage page as the target storage area, and write the to-be-written data into the available storage page. If there is no available storage page in the storage list, an idle storage block is obtained from the SSD, and the storage device uses a first storage page in the idle storage block as the target storage area, and writes the to-be-written data into the first storage page.

After completing writing of the to-be-written data in a current storage page, the storage device adds a next storage page to a corresponding storage list. For example, if there is an available storage page in the storage list, the storage device adds a next page of the available storage page to the storage list after completing data writing. If there is no available storage page in the storage list, after writing data into a first storage page, the storage device adds a second storage page to the storage list.

It should be understood that in this embodiment of this application, the storage list may be referred to as a “stack”. For example, a storage list corresponding to an LSB page type is referred to as an “LSB stack”, a storage list corresponding to a CSB page type is referred to as a “CSB stack”, and a storage list corresponding to an MSB page type is referred to as an “MSB stack”.

For example, as shown in FIG. 12 and FIG. 13, the storage device may divide a block storage area into three types of pages. Specifically, in FIG. 12, the storage device may respectively attach a plurality of pages to areas of corresponding types. The storage device attaches Block 13 Page 50, Block 18 Page 48, Block 33 Page 1, and Block 5 Page 0 to the LSB stack, attaches Block 98 Page 49, Block 22 Page 43, Block 76 Page 35, and Block 66 Page 17 to the CSB stack, and attaches Block 1 Page 157, Block 27 Page 139, Block 39 Page 121, and Block 9 Page 112 to the MSB stack. The storage device may store the to-be-written data in at least one idle page in a corresponding stack based on the type of to-be-written data.

Optionally, the storage device records currently available pages in a block in different storage lists.

Specifically, the pages in the block are sequentially numbered, and the storage device stores data based on a page sequence. To be specific, if a page 48 in a block is not used, a page 49 cannot directly be used for data storage.

The storage device records a currently available page in a storage list. If there is a page into which data is being written in a block of the storage device, another page in the block is an unavailable page. After the storage device completes writing of the page, the storage device may store a next page in the corresponding storage list.

For example, different types of pages (an LSB page, a CSB page, and an MSB page) may alternately occur. Pages in a block 18 shown in FIG. 5 are used as an example for description. After data is stored in Block 18 Page 48 in an LSB area, following data needs to be stored in Block 18 Page 50; however, Block 18 Page 49 belongs to a CSB area, and if no data is stored in Block 18 Page 49, data may not be directly stored in Block 18 Page 50 belonging to the LSB area. In this way, the storage device can attach, to the CSB stack, Block 18 Page 49 that can be used for data storage, and then, Block 18 Page 49 can be used to write data.

It should be noted that in this embodiment, a page that cannot be used for data storage is not stored in the storage list.

It should be understood that available pages of a same type in different blocks are stored in a same storage list.

Optionally, if there is no available page in a storage list corresponding to the page type corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written, the storage device may find a new block, attach a page 0 to the corresponding storage list, and then start storing data.

Optionally, if there is no available page in the storage list corresponding to the page type corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written, the storage device may determine a page having higher performance as the target storage area. In other words, the data is processed by using the page having higher performance. In this way, a resource can be fully used, and data congestion caused because the data waits for a proper storage area is avoided.

For example, if a page type corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written is an MSB page, and there is no idle page in a storage list corresponding to the MSB page, the storage device may determine at least one available page in a CSB page as the target storage area, or determine at least one available page in an LSB page as the target storage area. If a storage area of the type of storage area that is in the SSD and into which the to-be-written data is written is a CSB page, and there is no idle page in the CSB page, the storage device determines at least one idle page in the LSB page as the target storage area.

It should be understood that the storage device may also determine a page having lower performance as the target storage area. In this way, data processing efficiency can also be improved when there is no idle storage area in a page having higher performance. This is not limited in this application.

Optionally, the storage device may determine, based on the type of to-be-written data, both an idle block that meets a requirement of the to-be-written data and an idle page that meets the requirement of the to-be-written data. For example, the storage device may use, as the target storage area, at least one page that belongs to an LSB page area and that is in a block in an MLC area.

Optionally, when the storage device determines the target storage area in a storage area based on the type of to-be-written data, an area of an update type in the storage area may be selected based on the type of to-be-written data, and at least one page in the area of the update type of the type of storage area that is in the SSD and into which the to-be-written data is written is used as the target storage area. Storage areas include areas of at least two update types, and storage data in any two of the areas of the at least two update types is updated at different frequencies.

Specifically, the storage device divides the storage areas into a plurality of storage areas of a plurality of update types based on frequencies of updating storage data. Because the storage device has limited time to store data, the storage device may select, based on the type of to-be-written data, a proper area of an update type to store the data. For example, the storage device may preset a mapping relationship between the type of to-be-written data and an update type of an area, and the storage device may determine the area of the update type based on the mapping relationship and the type of to-be-written data. In this way, impact on system performance that is caused by frequent data inspection and updating caused because an improper area of an update type is selected is avoided, or reduction in data reliability that is caused by an excessively low inspection and updating rate is avoided. Therefore, in this embodiment of this application, reliability of different data can be implemented without affecting system performance.

For example, as shown in FIG. 9, the four storage areas: the SLC area, the MLC area, the TLC area, and the QLC area in the storage area may be replaced with the areas of the plurality of update types.

It should be understood that an area of each update type may be a page, or may be any one of a device, a target, a LUN, a plane, and a block. This is not limited in this application.

It should also be understood that the areas of the plurality of update types may have a same capacity, or some areas of the update types may have different capacities, or all the areas of the update types may have different capacities.

Optionally, the storage device may also use at least two of the three types of storage areas: the block storage area, the page, and the area of the update type as target storage areas. For example, the storage device may use at least one page that belongs to not only an LSB page but also an area of an update type in a block in the MLC area as the target storage area.

1104. The storage device writes the to-be-written data into the target storage area.

Therefore, in the data writing method in this embodiment of this application, the storage device receives the write command that carries the type of to-be-written data, determines, based on the type of to-be-written data, the type of storage page into which the to-be-written data is written, and then determines, based on the type of storage page, a target storage page into which the to-be-written data is written. In this way, the storage device can store the data in a proper storage page. In other words, the storage device can meet different requirements of applications. Therefore, data processing efficiency and system performance are improved.

FIG. 14 is a schematic block diagram of a storage device 1400 according to an embodiment of this application. As shown in FIG. 14, the storage device 1400 includes a receiving module 1410 and a processing module 1420.

The receiving module 1410 is configured to receive a write command, where the write command carries a type of to-be-written data.

The processing module 1420 is configured to determine, based on the type of to-be-written data, a type of storage area that is in the SSD and into which the to-be-written data is written, where the SSD includes a plurality of types of storage areas.

The processing module 1420 is further configured to determine, based on the type of storage area, a target storage area into which the to-be-written data is written.

The processing module 1420 is further configured to write the to-be-written data into the target storage area.

Optionally, the SSD stores a correspondence between a data type and a storage area type, and the processing module 1420 is specifically configured to: determine, based on the type of to-be-written data and the correspondence, a type of target storage area into which the to-be-written data is written.

Optionally, the SSD includes a plurality of storage blocks, the SSD is divided into different types of storage areas based on types of the storage blocks, and the correspondence is a correspondence between the data type and a storage block type.

Optionally, the SSD includes a plurality of storage blocks, each storage block includes at least one type of storage page, the SSD is divided into different types of storage areas based on storage page types, and the correspondence is a correspondence between the data type and the storage page type.

Optionally, different types of each storage pages are corresponding to one storage list, and each storage list records one type of storage page.

The processing module 1420 is specifically configured to:

find, based on a storage page type, an available storage page in a storage list corresponding to the storage page type, and use the available storage page as the target storage area; and

if there is an available storage page in the storage list, use the available storage page as the target storage area; or

if there is no available storage page in the storage list, obtain an idle storage block in the SSD, and use a first storage page in the idle storage block as the target storage area.

Optionally, the SSD includes at least two of an SLC area, an MLC area, a TLC area, and a QLC area, performance of the SLC area, the MLC area, the TLC area, and the QLC area sequentially decreases, and if there is no idle storage page in all storage blocks in a storage area corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written, the processing module 1420 converts a type of at least one block that includes an idle storage page and that is in a storage area having lower performance than the type of storage area that is in the SSD and into which the to-be-written data is written to a type that is the same as a type of storage area of the type of storage area that is in the SSD and into which the to-be-written data is written.

Optionally, the storage block includes at least two of an LSB page, a CSB page, and the MSB page, performance of the LSB page, the CSB page, and the MSB page sequentially decreases, and the processing module 1420 is specifically configured to:

if a storage area of the type of storage area that is in the SSD and into which the to-be-written data is written is the MSB page or the CSB page, and there is no available storage page in the storage area of the type of storage area that is in the SSD and into which the to-be-written data is written, determine, as the target storage area, at least one available storage page having higher performance than the type of storage area that is in the SSD and into which the to-be-written data is written.

Therefore, the storage device in this embodiment of this application receives the write command that carries the type of to-be-written data, determines, based on the type of to-be-written data, the type of storage area into which the to-be-written data is written, and then determines, based on the type of storage area, the target storage area into which the to-be-written data is written. In this way, the storage device can store the data in a proper storage area. In other words, the storage device can meet different requirements of applications. Therefore, data processing efficiency and system performance are improved.

It should be understood that the storage device 1400 in this embodiment of this application may be corresponding to the storage device in the data writing method in the embodiment shown in FIG. 7, and the foregoing and other management operations and/or functions of the modules in the storage device 1400 are separately used to implement corresponding steps of the foregoing methods. For brevity, details are not described herein again.

In this embodiment of this application, the receiving module 1410 may be implemented by a transceiver, and the processing module 1420 may be implemented by a processor. As shown in FIG. 15, the storage device 1500 may include a transceiver 1510, a processor 1520, and a memory 1530. The memory 1530 may be configured to store indication information, and may be further configured to store code, an instruction, and the like executed by the processor 1520.

It should be understood that the processor 1520 may be an integrated circuit chip and has a signal processing capability. In an implementation process, steps in the foregoing method embodiments can be implemented by using a hardware integrated logical circuit in the processor, or by using instructions in a form of software. The processor may be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or another programmable logical device, a discrete gate or transistor logic device, or a discrete hardware component. The processor may implement or perform the methods, the steps, and logical block diagrams that are disclosed in the embodiments of the present application. The general purpose processor may be a microprocessor, or the processor may be any conventional processor or the like. Steps of the methods disclosed with reference to the embodiments of the present application may be directly executed and accomplished by using a hardware decoding processor, or may be executed and accomplished by using a combination of hardware and software modules in the decoding processor. A software module may be located in a mature storage medium in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, or the like. The storage medium is located in the memory, and a processor reads information in the memory and completes the steps in the foregoing methods in combination with hardware of the processor.

It may be understood that the memory 1530 in the embodiments of the present application may be a volatile memory or a nonvolatile memory, or may include a volatile memory and a nonvolatile memory. The nonvolatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), used as an external cache. Through example but not limitative description, many forms of RAMs may be used, for example, a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM), and a direct rambus random access memory (DR RAM).

It should be noted that the memory described in the embodiments of this application is intended to include but not limited to these memories and any memory of another proper type.

The embodiments of this application further provide a computer storage medium, and the computer storage medium may store a program instruction for performing any of the foregoing methods.

Optionally, the storage medium may be specifically the memory 1530.

The embodiments of this application further provide a system chip. The system chip includes an input/output interface, at least one processor, at least one memory, and a bus. The at least one memory is configured to store an instruction, and the at least one processor is configured to invoke the instruction in the at least one memory to perform an operation of the method in the foregoing embodiments.

The processor included in the system chip in the embodiments of this application is configured to support a distributed unit, a centralized unit, and a storage device in implementing functions in the foregoing embodiments, for example, a function of generating or processing data and/or information in the foregoing methods.

In a possible design, the memory of the chip system is configured to store a necessary program instruction and necessary data in a distributed unit, a centralized unit, and a terminal device. The chip system may include a chip, or may include a chip and another discrete device. It should be understood that data and/or information processed by the chip may be from an application, and processed data and/or processed information may also be sent to the application. This is not limited in this application.

A person of ordinary skill in the art may be aware that, in combination with the examples described in the embodiments disclosed in this specification, units and algorithm steps may be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed by hardware or software depends on particular applications and design constraint conditions of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this application.

It may be clearly understood by a person skilled in the art that, for the purpose of convenient and brief description, for a detailed working process of the foregoing system, apparatus, and unit, refer to a corresponding process in the foregoing method embodiments. Details are not described herein again.

In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the described apparatus embodiment is merely an example. For example, the unit division is merely logical function division and may be other division in actual implementation. For example, a plurality of units or components may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented by using some interfaces. The indirect couplings or communication connections between the apparatuses or units may be implemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units may be selected based on actual requirements to achieve the objectives of the solutions of the embodiments.

In addition, functional units in the embodiments of this application may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units are integrated into one unit.

When the functions are implemented in the form of a software functional unit and sold or used as an independent product, the functions may be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of this application essentially, or the part contributing to the prior art, or some of the technical solutions may be implemented in a form of a software product. The computer software product is stored in a storage medium, and includes several instructions for instructing a computer device (which may be a personal computer, a server, or a network device) to perform all or some of the steps of the methods described in the embodiments of this application. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc.

The foregoing descriptions are merely specific implementations of this application, but are not intended to limit the protection scope of this application. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in this application shall fall within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims. 

What is claimed is:
 1. A data writing method, applied to a solid-state storage device (SSD), wherein the method comprises: receiving a write command, wherein the write command carries a type of to-be-written data; determining, based on the type of to-be-written data, a type of storage area that is in the SSD and into which the to-be-written data is written, wherein the SSD comprises a plurality of types of storage areas; determining, based on the type of storage area, a target storage area into which the to-be-written data is written; and writing the to-be-written data into the target storage area.
 2. The method according to claim 1, wherein the SSD stores a correspondence between a data type and a storage area type, and the determining, based on the type of to-be-written data, the type of storage area that is in the SSD and into which the to-be-written data is written comprises: determining, based on the type of to-be-written data and the correspondence, a type of target storage area into which the to-be-written data is written.
 3. The method according to claim 2, wherein the SSD comprises a plurality of storage blocks, the SSD is divided into different types of storage areas based on types of the storage blocks, and the correspondence is a correspondence between the data type and a storage block type.
 4. The method according to claim 3, wherein the SSD comprises at least two of an SLC (single level cell) area, an MLC (multi-level cell) area, a TLC (triple level cell) area, and a QLC (quad level cell) area, performance of the SLC area, the MLC area, the TLC area, and the QLC area sequentially decreases, and before the determining, based on the type of storage area, the target storage area into which the to-be-written data is written, the method further comprises: if there is no idle storage page in all storage blocks in a storage area corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written, converting a type of at least one block that comprises an idle storage page and that is in a storage area having lower performance than a storage area corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written to a type that is the same as a type of the storage area corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written.
 5. The method according to claim 2, wherein the SSD comprises a plurality of storage blocks, each storage block comprises at least one type of storage page, and the correspondence is a correspondence between the data type and a storage page type.
 6. The method according to claim 5, wherein different types of each storage pages are corresponding to one storage list, and each storage list records one type of storage page; and the determining, based on the type of storage area, the target storage area into which the to-be-written data is written comprises: finding, based on the storage page type, an available storage page in a storage list corresponding to the storage page type, and using the available storage page as the target storage area; and if there is an available storage page in the storage list, using the available storage page as the target storage area; or if there is no available storage page in the storage list, obtaining an idle storage block in the SSD, and using a first storage page in the idle storage block as the target storage area.
 7. The method according to claim 5, wherein the storage block comprises at least two of an LSB (least significant bit) page, a CSB (central significant bit) page, and an MSB (most significant bit) page, performance of the LSB page, the CSB page, and the MSB page sequentially decreases, and the determining, based on the type of storage area, the target storage area into which the to-be-written data is written comprises: if a storage area corresponding the type of storage area that is in the SSD and into which the to-be-written data is written is the MSB page or the CSB page, and there is no available storage page in the storage area corresponding the type of storage area that is in the SSD and into which the to-be-written data is written, determining, as the target storage area, at least one available storage page having higher performance than the storage area corresponding the type of storage area that is in the SSD and into which the to-be-written data is written.
 8. A solid-state device SSD, comprising: a memory storing instructions; and a processor coupled to the memory to execute the instructions to: receive a write command, wherein the write command carries a type of to-be-written data; and determine, based on the type of to-be-written data, a type of storage area that is in the SSD and into which the to-be-written data is written, wherein the SSD comprises a plurality of types of storage areas, determine, based on the type of storage area, a target storage area into which the to-be-written data is written; and write the to-be-written data into the target storage area.
 9. The SSD according to claim 8, wherein the SSD stores a correspondence between a data type and a storage area type, and when performing the operation of determining the type of storage area that is in the SSD and into which the to-be-written data is written, the processor is configured to: determine, based on the type of to-be-written data and the correspondence, a type of target storage area into which the to-be-written data is written.
 10. The SSD according to claim 9, wherein the SSD comprises a plurality of storage blocks, the SSD is divided into different types of storage areas based on types of the storage blocks, and the correspondence is a correspondence between the data type and a storage block type.
 11. The SSD according to claim 10, wherein the SSD comprises at least two of an SLC (single level cell) area, an MLC (multi-level cell) area, a TLC (triple level cell) area, and a QLC (quad level cell) area, performance of the SLC area, the MLC area, the TLC area, and the QLC area sequentially decreases, and if there is no idle storage page in all storage blocks in a storage area corresponding to the type of storage area that is in the SSD and into which the to-be-written data is written, the processor is further configured to convert a type of at least one block that comprises an idle storage page and that is in a storage area having lower performance than the type of storage area that is in the SSD and into which the to-be-written data is written to a type that is the same as a type of storage area of the type of storage area that is in the SSD and into which the to-be-written data is written.
 12. The SSD according to claim 9, wherein the SSD comprises a plurality of storage blocks, each storage block comprises at least one type of storage page, the SSD is divided into different types of storage areas based on storage page types, and the correspondence is a correspondence between the data type and the storage page type.
 13. The SSD according to claim 12, wherein different types of each storage pages are corresponding to one storage list, and each storage list records one type of storage page; and when performing the operation of determining the target storage area into which the to-be-written data is written, the processor is configured to: find, based on the storage page type, an available storage page in a storage list corresponding to the storage page type, and use the available storage page as the target storage area; and if there is an available storage page in the storage list, use the available storage page as the target storage area; or if there is no available storage page in the storage list, obtain an idle storage block in the SSD, and use a first storage page in the idle storage block as the target storage area.
 14. The SSD according to claim 12, wherein the storage block comprises at least two of an LSB (least significant bit) page, a CSB (central significant bit) page, and the MSB (most significant bit) page, performance of the LSB page, the CSB page, and the MSB page sequentially decreases, and when performing the operation of determining a target storage area into which the to-be-written data is written, the processor is configured to: if a storage area corresponding the type of storage area that is in the SSD and into which the to-be-written data is written is the MSB page or the CSB page, and there is no available storage page in the storage area corresponding the type of storage area that is in the SSD and into which the to-be-written data is written, determine, as the target storage area, at least one available storage page having higher performance than the storage area corresponding the type of storage area that is in the SSD and into which the to-be-written data is written. 